package Servlet.ComprobantePago;

import java.io.IOException;
import java.util.Collection;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.JOptionPane;

import com.huellas.bean.ListadoCitasComprobanteBean;
import com.huellas.negocio.GestionComprobantes;

/**
 * Servlet implementation class PrevieCitaPagarServlet
 */
@WebServlet("/PrevieCitaPagarServlet")
public class PrevieCitaPagarServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public PrevieCitaPagarServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int CodeCita = Integer.parseInt(request.getParameter("CodCita"));
		GestionComprobantes gc = new GestionComprobantes();
		try {
			String FechaActual = gc.RetornaFechaActual();
			   Collection<ListadoCitasComprobanteBean> DatosCita = gc.ListadocitaComprobante(CodeCita, 0, "N");
			   Collection<ListadoCitasComprobanteBean>DetalleCita = gc.Listar_Detalle_Para_Comprobante(CodeCita);
			   if(DetalleCita.size()==0){
				   request.setAttribute("FlgDetalle", "F");   
			   }else {
				   request.setAttribute("FlgDetalle", "V");
			   }
			   request.setAttribute("CodeCita", CodeCita);
				request.setAttribute("DatosCita", DatosCita);
				request.setAttribute("FechaActual", FechaActual);
				request.setAttribute("DetalleCita", DetalleCita);
				RequestDispatcher rd = request.getRequestDispatcher("PreviewCitaPagar.jsp");
				rd.forward(request, response);
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
